//package morenoapp.components.input;
//
//import java.awt.event.ActionEvent;
//import java.awt.event.ActionListener;
//import java.util.ArrayList;
//import java.util.HashSet;
//import java.util.List;
//import java.util.Set;
//import javax.swing.event.ListSelectionEvent;
//import javax.swing.event.ListSelectionListener;
//import javax.swing.table.TableCellEditor;
//import morenoapp.MorenoApp;
//import morenoapp.components.common.table.column.MorenoCustomTableColumnModel;
//import morenoapp.components.common.table.renderer.RespondentProxyPanelTableCellRenderer;
//import morenoapp.components.input.MorenoRespondentSelecetionListener;
//import morenoapp.model.app.MorenoApplicationAdapter;
//import morenoapp.model.app.MorenoApplicationListener;
//import morenoapp.model.app.MorenoApplicationVetoException;
//import morenoapp.model.data.MorenoRespondentFace;
//import morenoapp.util.I18N;
//import org.jdesktop.application.Action;
//
///**
// * Конфигурация исследования.
// *
// * @author dmitry.mamonov
// */
//@Deprecated
//public class InputRespondentsJPanel extends javax.swing.JPanel {
//    private Set<MorenoRespondentSelecetionListener> morenoRespondentSelecetionListeners = new HashSet<MorenoRespondentSelecetionListener>();
//    private MorenoApplicationListener applicationListener;
//
//    /** Creates new form InputJPanel */
//    public InputRespondentsJPanel() {
//        initComponents();
//
//        initComponentsSpecial();
//
//        //Добавляем слушателя приложения
//        applicationListener = new MorenoApplicationAdapter() {
//            @Override
//            public void onSaveDoCommitChanges() throws MorenoApplicationVetoException {
//                ///Применяем изменения если это возможно, в противном случае запрещаем сохранение.
//                if (jTableRespondents.isEditing()) {
//                    TableCellEditor editor = jTableRespondents.getCellEditor();
//                    if (!editor.stopCellEditing()) {
//                        throw new MorenoApplicationVetoException(I18N.get("message.please_complete_editing_in_respondents_table"));
//                    }
//                }
//            }
//        };
//        MorenoApp.getApplicationData().addApplicationListener(applicationListener);
//
//        jTableRespondents.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
//            @Override
//            public void valueChanged(ListSelectionEvent e) {
//                if (!e.getValueIsAdjusting()) {
//                    if (jTableRespondents.getSelectedRowCount() == 1) {
//                        fireMorenoRespondentSeleceted(MorenoApp.getModel().getRespondentsList().get(jTableRespondents.getSelectedRow()));
//                    } else {
//                        fireMorenoRespondentSeleceted(null);
//                    }
//                }
//            }
//        });
//
//    }
//
//    /** This method is called from within the constructor to
//     * initialize the form.
//     * WARNING: Do NOT modify this code. The content of this method is
//     * always regenerated by the Form Editor.
//     */
/*
//    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jToolBar = new javax.swing.JToolBar();
        jButtonAddRespondent = new javax.swing.JButton();
        jButtonRemoveRespondent = new javax.swing.JButton();
        jButtonImportRespondents = new javax.swing.JButton();
        jButtonSortRespondentsByNameSex = new javax.swing.JButton();
        jButtonSortRespondentsBySexName = new javax.swing.JButton();
        jScrollPane = new javax.swing.JScrollPane();
        jTableRespondents = new javax.swing.JTable();

        setName("panelRespondents"); // NOI18N

        jToolBar.setFloatable(false);
        jToolBar.setRollover(true);
        jToolBar.setName("jToolBar"); // NOI18N

        jButtonAddRespondent.setFocusable(false);
        jButtonAddRespondent.setName("buttonAddRespondent"); // NOI18N
        jButtonAddRespondent.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar.add(jButtonAddRespondent);

        jButtonRemoveRespondent.setFocusable(false);
        jButtonRemoveRespondent.setName("buttonRemoveRespondent"); // NOI18N
        jButtonRemoveRespondent.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar.add(jButtonRemoveRespondent);

        jButtonImportRespondents.setFocusable(false);
        jButtonImportRespondents.setName("buttonImportRespondents"); // NOI18N
        jButtonImportRespondents.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar.add(jButtonImportRespondents);

        jButtonSortRespondentsByNameSex.setFocusable(false);
        jButtonSortRespondentsByNameSex.setName("buttonSortRespondentsByNameSex"); // NOI18N
        jButtonSortRespondentsByNameSex.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar.add(jButtonSortRespondentsByNameSex);

        jButtonSortRespondentsBySexName.setFocusable(false);
        jButtonSortRespondentsBySexName.setName("buttonSortRespondentsBySexName"); // NOI18N
        jButtonSortRespondentsBySexName.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar.add(jButtonSortRespondentsBySexName);

        jScrollPane.setName("jScrollPane"); // NOI18N

        jTableRespondents.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jTableRespondents.setName("jTableRespondents"); // NOI18N
        jScrollPane.setViewportView(jTableRespondents);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jToolBar, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 209, Short.MAX_VALUE)
            .addComponent(jScrollPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 209, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jToolBar, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 269, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonAddRespondent;
    private javax.swing.JButton jButtonImportRespondents;
    private javax.swing.JButton jButtonRemoveRespondent;
    private javax.swing.JButton jButtonSortRespondentsByNameSex;
    private javax.swing.JButton jButtonSortRespondentsBySexName;
    private javax.swing.JScrollPane jScrollPane;
    private javax.swing.JTable jTableRespondents;
    private javax.swing.JToolBar jToolBar;
    // End of variables declaration//GEN-END:variables
*/
//    // Begin - special variables
//    private InputRespondentsTableModel configRespondentsTableModel = new InputRespondentsTableModel();
//    // End   - special variables
//
//    private void initComponentsSpecial() {
//        jTableRespondents.setColumnModel(new MorenoCustomTableColumnModel(configRespondentsTableModel));
//        jTableRespondents.setModel(configRespondentsTableModel);
//
//        for (Class c : new Class[]{Integer.class, String.class, Boolean.class}) {
//            jTableRespondents.setDefaultRenderer(c, new RespondentProxyPanelTableCellRenderer(jTableRespondents.getDefaultRenderer(c)));
//        }
//
//        jButtonAddRespondent.addActionListener(new ActionListener() {
//            @Override
//            public void actionPerformed(ActionEvent e) {
//                actionAddRespondent();
//            }
//        });
//        jButtonImportRespondents.addActionListener(new ActionListener() {
//            @Override
//            public void actionPerformed(ActionEvent e) {
//                actionImportRespondentsList();
//            }
//        });
//        jButtonRemoveRespondent.addActionListener(new ActionListener() {
//            @Override
//            public void actionPerformed(ActionEvent e) {
//                actionDeleteSelectedRespondents();
//            }
//        });
//        jButtonSortRespondentsByNameSex.addActionListener(new ActionListener() {
//            @Override
//            public void actionPerformed(ActionEvent e) {
//                actionSortRespondents();
//            }
//        });
//        jButtonSortRespondentsBySexName.addActionListener(new ActionListener() {
//            @Override
//            public void actionPerformed(ActionEvent e) {
//                actionSortRespondentsBySex();
//            }
//        });
//    }
//
//    @Action
//    public void actionAddRespondent() {
//        configRespondentsTableModel.addNewRespondent();
//    }
//
//    @Action
//    public void actionSortRespondents() {
//        configRespondentsTableModel.sortRespondentsListByName();
//    }
//
//    @Action
//    public void actionSortRespondentsBySex() {
//        configRespondentsTableModel.sortRespondentsListBySex();
//    }
//
//    @Action
//    public void actionRefresh() {
//        //configRespondentsTableModel.refresh();
//    }
//
//    @Action
//    public void actionDeleteSelectedRespondents() {
//        List<MorenoRespondentFace> respondents = new ArrayList<MorenoRespondentFace>();
//        for (int row : jTableRespondents.getSelectedRows()) {
//            respondents.add(configRespondentsTableModel.getRespondentAtRow(row));
//        }
//        MorenoApp.getApplicationData().getMorenoModelProxy().deleteRespondents(respondents);
//    }
//
//    @Action
//    public void actionImportRespondentsList() {
//        ImportRespondentsListJDialog importDialog = new ImportRespondentsListJDialog(MorenoApp.getApplication().getMainFrame(), true);
//        importDialog.setVisible(true);
//    }
//
//    public void addMorenoRespondentSelecetionListener(MorenoRespondentSelecetionListener lst) {
//        morenoRespondentSelecetionListeners.add(lst);
//    }
//
//    public void removeMorenoRespondentSelecetionListener(MorenoRespondentSelecetionListener lst) {
//        morenoRespondentSelecetionListeners.remove(lst);
//    }
//
//    protected void fireMorenoRespondentSeleceted(MorenoRespondentFace aRespondent) {
//        for (MorenoRespondentSelecetionListener lst : morenoRespondentSelecetionListeners) {
//            lst.onRespondentSelected(aRespondent);
//        }
//    }}
